#include "userinfo.h"
#include <QDebug>
UserInfo::UserInfo()
{
    m_id = -1;
    m_name.clear();
    m_head.clear();
}

UserInfo::UserInfo(int id, const QString &name,const QString &head)
{
    m_id = id;
    m_name = name;
    m_head = head;
}

UserInfoList::UserInfoList()
{
    m_userCount = 0;
    m_userNameList.clear();
    m_userInfoMap.clear();
}

UserInfo UserInfoList::getUserInfo(QString name)
{
    return m_userInfoMap.value(name);
}
QStringList &UserInfoList::getUserNameList()
{
    return m_userNameList;
}

void UserInfoList::appendUserInfo(const UserInfo &info)
{
    m_userCount++;
    m_userNameList.append(info.m_name);
    m_userInfoMap.insert(info.m_name, info);
}
void UserInfoList::removeUserInfo(const QString &name)
{
    if(m_userInfoMap.contains(name))
    {
        m_userCount--;
        m_userNameList.removeOne(name);
        m_userInfoMap.remove(name);
    }
}

bool UserInfoList::isExistUser(const QString &name)
{
    return m_userInfoMap.contains(name);
}
